@php use App\Models\Product\ProductClassify;use App\Util\User; @endphp
{{--<style>
    .sticky-row {
        position: sticky;
        top: 0;
        left: 0;
        background: #f4f4f4;
    }

    /*表头*/
    table thead {
        z-index: 2;
        position: sticky;
        position: -webkit-sticky;
        top: 0;
        background: #f4f4f4;
    }
    table thead tr th:first-child{
        position: sticky;
        top: 0;
        left: 0;
        background: #f4f4f4;
    }
    th:nth-child(2){
        position: sticky;
        left: 4.9%;
        background: #f4f4f4;
    }
    th:nth-child(3){
        position: sticky;
        left: 9.6%;
        background: #f4f4f4;
    }
    th:nth-child(4){
        position: sticky;
        left: 12%;
        background: #f4f4f4;
    }
    th:nth-child(5){
        position: sticky;
        left: 14.7%;
        background: #f4f4f4;
    }
    th:nth-child(6){
        position: sticky;
        left: 18%;
        background: #f4f4f4;
    }

    /*表格*/
    table tbody tr td:first-child {
        z-index: 1;
        position: sticky;
        position: -webkit-sticky;
        left: 0;
        background: #f4f4f4;
    }
    td:nth-child(2){
        position: sticky;
        left: 4.9%;
        background: #f4f4f4;
    }
    td:nth-child(3){
        position: sticky;
        left: 9.6%;
        background: #f4f4f4;
    }
    td:nth-child(4){
        position: sticky;
        left: 12%;
        background: #f4f4f4;
    }
    td:nth-child(5){
        position: sticky;
        left: 14.7%;
        background: #f4f4f4;
    }
    td:nth-child(6){
        position: sticky;
        left: 18%;
        background: #f4f4f4;
    }
</style>--}}
<table class="table table-hover">
    <thead>
    <tr>
        @foreach($headers as $filed => $item)
            <th>{{ $item['title'] }}</th>
        @endforeach
    </tr>
    <tr style="color:#f56f9c">
        @foreach($headers as $filed => $item)
            @if($filed == 'report_date')
                <td class="sticky-row">TTL</td>
            @elseif($filed == 'profit_rate')
                <td>{{ floatval($total['sales_amount_rmb']) > 0 ? round($total['profit_rmb'] / $total['sales_amount_rmb'],5) * 100 .'%' : '0%' }}</td>
            @elseif($filed == 'total_rate')
                <td>{{ floatval($total['sales_amount_rmb']) > 0 ? round($total['total_rmb'] / $total['sales_amount_rmb'],5) * 100 .'%' : '0%' }}</td>
            @elseif($item['sumField'])
                <td>{{ array_key_exists($filed,$total) ? $total[$filed] : '' }}</td>
            @else
                <td></td>
            @endif
        @endforeach
    </tr>
    </thead>
    <tbody>
    @foreach($paginator as $row)
        <tr>
            <td>{{ $row->report_date }}</td>
            <td>{{ $row->sku->psku_code ?? '' }}</td>
            <td>{{ $row->sku->psku_cn ?? '' }}</td>
            <td>{{ ProductClassify::$_season[$row->classify->season ?? 3] }}</td>
            <td>{{ $row->classify->title ?? '' }}</td>
            <td>{{ User::getUsernameById($row->seller_id) }}</td>
            <td>{{ $row->rate_odds }}</td>
            <td>{{ $row->sales_volume }}</td>
            <td>{{ $row->sales_amount }}</td>
            <td>{{ $row->sales_amount_rmb }}</td>
            <td>{{ $row->refund_num }}</td>
            <td>{{ $row->refund_amount }}</td>
            <td>{{ $row->refund_amount_rmb }}</td>
            <td>{{ $row->thfba }}</td>
            <td>{{ $row->thfba_rmb }}</td>
            <td>{{ $row->purchase_price_rmb }}</td>
            <td>{{ $row->t_purchase_price_rmb }}</td>
            <td>{{ $row->t_shipment_price_rmb }}</td>
            <td>{{ $row->other_fee_rmb }}</td>
            <td>{{ $row->system_use_pc_fee }}</td>
            <td>{{ $row->system_use_pc_fee_rmb }}</td>
            <td>{{ $row->system_use_sp_fee }}</td>
            <td>{{ $row->system_use_sp_fee_rmb }}</td>
            <td>{{ $row->system_use_c_fee }}</td>
            <td>{{ $row->system_use_c_fee_rmb }}</td>
            <td>{{ $row->super_membership_rewards_fee }}</td>
            <td>{{ $row->super_membership_rewards_fee_rmb }}</td>
            <td>{{ $row->super_membership_system_use_fee }}</td>
            <td>{{ $row->super_membership_system_use_fee_rmb }}</td>
            <td>{{ $row->super_membership_selling_fee }}</td>
            <td>{{ $row->super_membership_selling_fee_rmb }}</td>
            <td>{{ $row->super_membership_selling_re_fee }}</td>
            <td>{{ $row->super_membership_selling_re_fee_rmb }}</td>
            <td>{{ $row->integral_pc_fee }}</td>
            <td>{{ $row->integral_pc_fee_rmb }}</td>
            <td>{{ $row->integral_sp_fee }}</td>
            <td>{{ $row->integral_sp_fee_rmb }}</td>
            <td>{{ $row->rakuten_pay_use_fee }}</td>
            <td>{{ $row->rakuten_pay_use_fee_rmb }}</td>
            <td>{{ $row->rakuten_pay_visa_fee }}</td>
            <td>{{ $row->rakuten_pay_visa_fee_rmb }}</td>
            <td>{{ $row->service_fee }}</td>
            <td>{{ $row->service_fee_rmb }}</td>
            <td>{{ $row->spend }}</td>
            <td>{{ $row->spend_rmb }}</td>
            <td>{{ $row->reimburse_rmb }}</td>
            <td>{{ $row->reimburse_os_rmb }}</td>
            <td>{{ $row->reimburse_profit_rmb }}</td>
            <td>{{ $row->profit_rmb }}</td>
            <td>{{ getPercentage($row->profit_rmb,$row->sales_amount_rmb) }}</td>
            <td>{{ $row->earning_rmb }}</td>
            <td>{{ $row->total }}</td>
            <td>{{ $row->total_rmb }}</td>
            <td>{{ getPercentage($row->total_rmb,$row->sales_amount_rmb) }}</td>
        </tr>
    @endforeach
    </tbody>
</table>
